package com.imooc.distributedemo.resume.leetcode;

/**
 * leetcode151  反转字符串
 */
public class Solution151 {

    public static void main(String[] args) {
        String str = " This is my   family!  ";
        String result = reverseStatement(str);
        System.out.println(result);
    }

    private static String reverseStatement(String str) {
        if(null == str || "".equals(str)){
            return "";
        }
        String[] tmp = str.split(" ");
        StringBuilder result = new StringBuilder("");
        for (int i = tmp.length-1; i >=0 ; i--) {
            result.append(tmp[i]);
            if(i!=0){
                result.append(" ");
            }
        }
        return result.toString().trim();
    }
}
